import { createStore } from "vuex";
import mA from "@/store/modules/moduleA";
import actions from "@/store/actions";
import mutations from "@/store/mutations";

const store = createStore({
  // 全局共享变量
  state() {
    return {
      count: 0,
      todos: [
        { id: 1, text: "学习", done: true },
        { id: 2, text: "打篮球", done: false },
      ],
    };
  },
  modules: {
    A: mA,
  },
  getters: {
    doneCount(state) {
      return state.todos.filter((todo) => todo.done === true).length;
    },
  },
  mutations,
  actions,
});

export default store;
